﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Xml.Serialization;

namespace FreeRecorderExplorer
{
    public class RecordItem : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;

        string name;

        public string Name
        {
            get { return name; }
            set 
            { 
                name = value;
                NotifyPropertyChanged("Name");
            }
        }

        TimeSpan duration;

        [XmlIgnore()]
        public TimeSpan Duration
        {
            get { return duration; }
            set
            {
                duration = value;
            }
        }

        [XmlElement("Duration")]
        public string DurationString
        {
            get
            {
                return this.duration.ToString(@"hh\:mm\:ss\.f");
            }
            set
            {
                this.duration = TimeSpan.Parse(value);
            }
        }

        [XmlIgnore()]
        public string DurationUI
        {
            get
            {
                return this.duration.ToString(@"h\:mm\:ss");
            }
        }

        [XmlIgnore()]
        public string CreationTimeString { get; set; }

        int size;
        public int Size
        {
            get
            {
                return size;
            }
            set
            {
                size = value;
            }
        }

        string description;

        public string Description
        {
            get { return description; }
            set 
            {                 
                description = value;
                NotifyPropertyChanged("Description");
            }
        }



        private void NotifyPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));                
            }
        }
    }
}
